<template>
	<view class="mainpadding">
		<!-- 积分box -->
		<view class="toububjt">
			<view class="dabtexxt textcenter" v-if="type == 1">{{userInfo.score}}</view>
			<view class="dabtexxt textcenter" v-if="type == 2">{{userInfo.money}}</view>
			<view class="dabtexxt textcenter" v-if="type == 3">{{userInfo.team_money}}</view>
			
			<view class="xiaobai nofonweight bigtext textcenter margin_top" v-if="type == 1">我的积分</view>
			<view class="xiaobai nofonweight bigtext textcenter margin_top" v-if="type == 2">我的佣金</view>
			<view class="xiaobai nofonweight bigtext textcenter margin_top" v-if="type == 3">团队奖励</view>
			<view class="margin_top flexcenter">
				<view class="baibtn1s " @click="jumper('/pages/mypage/zengsong')" v-if="type == 1">赠送 </view>
				<view class="baibtn1s" @click="jumper('/pages/mypage/zhuanhuan?type=1')" v-if="type == 2">转换 </view>
				<view class="baibtn1s" @click="jumper('/pages/mypage/zhuanhuan?type=2')" v-if="type == 3">转换 </view>
				<!-- <view class="baibtn1s " @click="jumper('/pages/mypage/tixian')" v-if="type == 2">提现 </view> -->
			</view>
		</view>
		<!-- 积分明细 -->
		<view class="margin_top">
			<view class="xiaohei fonweight bigtext">{{type==1?"积分":type==2?"佣金":"团队奖励"}}明细</view>
			<view class="flexcenter" v-if="list.data.length==0">
				<view class="placeholderimage" style="margin-top: 100rpx;" ></view>
			</view>
			<view class="mainpadding ffffff margin_top radius" v-if="list.data.length">
				<view class="flexbetween xiahuaxian shangj" v-for="item in list.data" :key="item.id">
					<view class="">
						<view class="xiaohei nofonweight titletext">{{item.memo}}</view>
						<view class="xiaohui nofonweight ershiba margin_top2">{{item.createtime_text}}</view>
					</view>
					<view class="xiaolan fonweight sanshier" v-if="type==1">{{item.score}}</view>
					<view class="xiaolan fonweight sanshier" v-if="type==2 || type==3">{{item.money}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				type: 1,//1积分，2佣金，3团队奖励
				userInfo:{},
				page: 1,
				limit: 12,
				list: {
					data: []
				},
			}
		},
		onLoad(options) {
			this.type = options.type
			let text = ""
			if (this.type == 1) {
				text = "我的积分"
			} else if (this.type == 2) {
				text = "我的佣金"
			}else if(this.type == 3){
				text = "团队奖励"
			}
			uni.setNavigationBarTitle({
				title: text
			});
			
		},
		onShow() {
			this.userinfo()
			this.init()
		},
		methods: {
			userinfo() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			init(isPage, page) { //提现记录
				let _this = this
				let url = "/api/user/getUserScoreLog"
				let data = {
					page: page || 1,
					limit: _this.limit
				}
				if(this.type==2){
					url = "/api/user/getUserMoneyLog"
				}
				if(this.type==3){
					url = "/api/user/getUserTeamMoneyLog"
				}
				httpRequest.request(url, 'GET', data, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							this.list = res.data
							_this.list.data = resList.data;
						}
					}
				}).catch(err => {
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			jumper(url) {
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.xiahuaxian:last-child {
		border: none;
		padding-bottom: 0;
	}

	.shangj {
		margin-top: 30rpx;
	}

	.shangj:first-child {
		margin-top: 0;
	}

	.baibtn1s {
		width: 194rpx;
		height: 65rpx;
		display: flex;
		align-items: center;
		justify-content: center;
		border-radius: 10rpx;
		border: 2rpx solid #FFFFFF;
		font-size: 28rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #fff;
	}

	.dabtexxt {
		font-size: 60rpx;
		color: #fff;
		font-weight: 800;
	}

	.toububjt {
		background-size: 100% 100%;
		width: 100%;
		box-sizing: border-box;
		padding: 76rpx 0 20rpx;
		background-image: url('@/static/image/sysem/jjtb.png');
	}
</style>